package com.tttn.docbao.adapter;

import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.tttn.docbao.R;
import com.tttn.docbao.fragment.TabGTFragment;
import com.tttn.docbao.fragment.TabPLFragment;
import com.tttn.docbao.fragment.TabSKFragment;
import com.tttn.docbao.fragment.TabTGFragment;
import com.tttn.docbao.fragment.TabTSFragment;
import com.tttn.docbao.fragment.TabTTFragment;
import com.tttn.docbao.fragment.TabTTHFragment;
import com.tttn.docbao.until.Core;

public class NewsAdapter extends FragmentPagerAdapter {
	private Context context;
	private String type;

	public NewsAdapter(FragmentManager childFragmentManager, Context context,
			String type) {
		super(childFragmentManager);
		this.context = context;
		this.type = type;
	}

	@Override
	public CharSequence getPageTitle(int position) {
		switch (Core.getType(type)) {
		case 1:
			return getPageTitle1(position);
		case 2:
			return getPageTitle2(position);
		default:
			return null;
		}
	}

	private CharSequence getPageTitle1(int position) {
		switch (position) {
		case 0:
			return context.getString(R.string.trangchu);
		case 1:
			return context.getString(R.string.thoisu);
		case 2:
			return context.getString(R.string.thegioi);
		case 3:
			return context.getString(R.string.thethao);
		case 4:
			return context.getString(R.string.phapluat);
		case 5:
			return context.getString(R.string.giaitri);
		case 6:
			return context.getString(R.string.suckhoe);
		default:
			return null;
		}
	}

	private CharSequence getPageTitle2(int position) {
		switch (position) {
		case 0:
			return context.getString(R.string.trangchu);
		case 1:
			return context.getString(R.string.thitruong);
		case 2:
			return context.getString(R.string.giaoduc);
		case 3:
			return context.getString(R.string.thethao);
		case 4:
			return context.getString(R.string.phapluat);
		case 5:
			return context.getString(R.string.giaitri);
		case 6:
			return context.getString(R.string.suckhoe);
		default:
			return null;
		}
	}

	@Override
	public Fragment getItem(int position) {
		switch (position) {
		case 0:
			return new TabTTFragment(type);
		case 1:
			return new TabTSFragment();
		case 2:
			return new TabTGFragment();
		case 3:
			return new TabTTHFragment();
		case 4:
			return new TabPLFragment();
		case 5:
			return new TabGTFragment();
		case 6:
			return new TabSKFragment();
		default:
			return null;
		}
	}

	@Override
	public int getCount() {
		return 7;
	}

}